Skip to content

always update to the correct head of Mercurial repositories #4600

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 23, 2024

Conversation

vladak
Copy link
Member

@vladak vladak commented Jul 23, 2024

When indexing a particular repository after a recent change, the incremental indexer run failed with:

org.opengrok.indexer.index.IndexDatabase$IndexerFault: attempting to add file '/on11sru-allbranch-clone/usr/man/on/en/xman8/ikeadm.8.xml' with date matching deleted document: 20171211230536714
        at org.opengrok.indexer.index.IndexDatabase.processFileHistoryBased(IndexDatabase.java:1779)
        at org.opengrok.indexer.index.IndexDatabase.indexDownUsingHistory(IndexDatabase.java:985)
        at org.opengrok.indexer.index.IndexDatabase.getIndexDownArgs(IndexDatabase.java:946)
        at org.opengrok.indexer.index.IndexDatabase.update(IndexDatabase.java:755)
        at org.opengrok.indexer.index.Indexer.lambda$doIndexerExecution$59(Indexer.java:1208)
        at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)

Digging into the problem, the changeset that was added was not reflected in the file-system changes. The mirroring logs said:

07/18/2024 04:09:42 PM - INFO: Synchronizing repository /ws-local/on11sru-allbranch-clone/usr/man
07/18/2024 04:09:43 PM - INFO: output of /usr/bin/hg branch:
07/18/2024 04:09:43 PM - INFO: default

07/18/2024 04:09:48 PM - INFO: output of /usr/bin/hg pull:
07/18/2024 04:09:48 PM - INFO: pulling from ssh://on-gate/on-gate/usr/man
searching for changes
adding changesets
adding manifests
adding file changes
added 1 changesets with 3 changes to 3 files
new changesets 5b82d16f6f44
(run 'hg update' to get a working copy)

07/18/2024 04:09:49 PM - INFO: output of /usr/bin/hg update --check:
07/18/2024 04:09:49 PM - INFO: 0 files updated, 0 files merged, 0 files removed, 0 files unresolved
updated to "53e7d284bbb4: Added tag st_020"
1 other heads for branch "default"

Basically, the mirroring for the repo executed these commands:

hg pull
hg update --check

What happened was that the update was done to some historical changeset instead of the tip so no files were actually updated (the output showing the 0 files updated). The incremental file detection using the changesets (history based reindex) rather than the file system traversal got the file list correctly however the time stamp was taken from the file system, hence the indexer failure.

The historical changeset 53e7d284bbb4 was actually a head (visible in the output from hg log --graph -b .) likely created inadvertently and later removed (it is not in a fresh clone of the repository) however it was already pulled, causing a situation with 2 heads. hg log --rev 'head() and branch(".")' shows two changesets - one correct one (5b82d16f6f44), one is the stub (53e7d284bbb4).

This change fixes the problem by using the head with maximum index.

@vladak vladak added the tools Python tools label Jul 23, 2024
@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Verified All contributors have signed the Oracle Contributor Agreement. label Jul 23, 2024
@vladak vladak requested a review from vlmarek July 23, 2024 13:17
@vladak vladak changed the title always update to the tip for Mercurial repositories always update to the tip of Mercurial repositories Jul 23, 2024
@vlmarek
Copy link
Member

vlmarek commented Jul 23, 2024

We had a little discussion with @vladak . What seems to be happening is that there were two heads on the actual branch. And hg update somehow ended up on the older head. My suggestion would be to call hg update --check --rev 'max(head() and branch("."))' which says "stay on the actual branch and pick the most recent head available".

@vlmarek
Copy link
Member

vlmarek commented Jul 23, 2024

BTW the hg update tip would update the repository to latest changeset with no respect for branches. So the repo might be switching between branches should there be more than one.

Copy link
Member

@vlmarek vlmarek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, thank you

@vladak vladak changed the title always update to the tip of Mercurial repositories always update to the correct head of Mercurial repositories Jul 23, 2024
@vladak vladak merged commit 4efb0fd into oracle:master Jul 23, 2024
9 checks passed
@vladak vladak deleted the tools_mercurial_update_tip branch July 23, 2024 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Verified All contributors have signed the Oracle Contributor Agreement. tools Python tools
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants